package com.sca.order.controller;

import com.sca.order.entity.api.BaseResult;
import com.sca.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuxianfei
 * @since 2020/11/13 17:08
 */
@Api
@RestController
@RequestMapping("/order/v1")
public class OrderController {

    private final OrderService orderService;

    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }

    @PostMapping("/add")
    @ApiOperation("初始化商品id")
    public BaseResult<?> addOrder(Integer userId, Long goodId, Integer num) throws Exception {
        orderService.submit(userId, goodId, num);
        return new BaseResult<>();
    }

}
